﻿using System;
using System.Collections.Generic;

namespace AutoDb {
	/// <summary>
	/// 
	/// </summary>
	sealed class DbTable : DbObject, IList<DbColumn> {
		private IList<DbColumn> m_columns;

		/// <summary>
		/// 
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="lineInfo"></param>
		public DbTable(string lineInfo)
			: base(lineInfo) {
			m_columns = new List<DbColumn>();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public int IndexOf(DbColumn item) {
			return m_columns.IndexOf(item);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <param name="item"></param>
		public void Insert(int index, DbColumn item) {
			m_columns.Insert(index, item);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		public void RemoveAt(int index) {
			m_columns.RemoveAt(index);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public DbColumn this[int index] {
			get {
				return m_columns[index];
			}
			set {
				m_columns[index] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item"></param>
		public void Add(DbColumn item) {
			m_columns.Add(item);
		}

		/// <summary>
		/// 
		/// </summary>
		public void Clear() {
			m_columns.Clear();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public bool Contains(DbColumn item) {
			return m_columns.Contains(item);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="array"></param>
		/// <param name="arrayIndex"></param>
		public void CopyTo(DbColumn[] array, int arrayIndex) {
			m_columns.CopyTo(array, arrayIndex);
		}

		/// <summary>
		/// 
		/// </summary>
		public int Count {
			get { return m_columns.Count; }
		}

		/// <summary>
		/// 
		/// </summary>
		public bool IsReadOnly {
			get { return false; }
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public bool Remove(DbColumn item) {
			return m_columns.Remove(item);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public IEnumerator<DbColumn> GetEnumerator() {
			return m_columns.GetEnumerator();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
			return GetEnumerator();
		}
	} // end of DbTable.
}
